package com.example.androidproject.utils;

import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.Parcelable;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;

import androidx.annotation.NonNull;

import com.example.androidproject.movie.activity.MoviePlayActivity;

import java.util.Timer;
import java.util.TimerTask;

import com.example.androidproject.R;

public class ScreenNoOperationTiming extends MoviePlayActivity {
    private String TAG = "GGSTUDY";
    public Timer mtimer;// 计时器，每1秒执行一次任务
    public long mLastActionTime;   // 上一次操作时间

    public ScreenNoOperationTiming() {
    }

    public ScreenNoOperationTiming(Timer mtimer) {
        this.mtimer = mtimer;
    }


    /**
     * 启动计时任务
     */
    public void startTimer() {
        // 初始化上次操作时间为登录成功的时间
        mLastActionTime = System.currentTimeMillis();
    }

    /**
     * 点击屏幕时重载计时
     *
     * @param ev
     * @return
     */
    public boolean dispatchTouchEvent(MotionEvent ev) {
        mLastActionTime = System.currentTimeMillis();
        return super.dispatchTouchEvent(ev);
    }

    /**
     * 停止计时
     */
    public void stopTimer() {
        mtimer.cancel();
    }

}
